<!DOCTYPE HTML PUBLIC "-//ORA//DTD CD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE>[Chapter 12] Integer</TITLE>
<META NAME="author" CONTENT="Mark Grand and Jonathan Knudsen">
<META NAME="date" CONTENT="Fri Aug  8 17:01:59 1997">
<META NAME="form" CONTENT="html">
<META NAME="metadata" CONTENT="dublincore.0.1">
<META NAME="objecttype" CONTENT="book part">
<META NAME="otheragent" CONTENT="gmat dbtohtml">
<META NAME="publisher" CONTENT="O'Reilly &amp; Associates, Inc.">
<META NAME="source" CONTENT="SGML">
<META NAME="subject" CONTENT="Java">
<META NAME="title" CONTENT="Java Fundamental Classes Reference">
<META HTTP-EQUIV="Content-Script-Type" CONTENT="text/javascript">
</HEAD>
<body vlink="#551a8b" alink="#ff0000" text="#000000" bgcolor="#FFFFFF" link="#0000ee">

<DIV CLASS=htmlnav>
<H1><a href='index.htm'><IMG SRC="gifs/smbanner.gif"
     ALT="Java Fundamental Classes Reference" border=0></a></H1>
<table width=515 border=0 cellpadding=0 cellspacing=0>
<tr>
<td width=172 align=left valign=top><A HREF="ch12_29.htm"><IMG SRC="gifs/txtpreva.gif" ALT="Previous" border=0></A></td>
<td width=171 align=center valign=top><B><FONT FACE="ARIEL,HELVETICA,HELV,SANSERIF" SIZE="-1">Chapter 12<br>The java.lang Package</FONT></B></TD>
<td width=172 align=right valign=top><A HREF="ch12_31.htm"><IMG SRC="gifs/txtnexta.gif" ALT="Next" border=0></A></td>
</tr>
</table>

&nbsp;
<hr align=left width=515>
</DIV>
<DIV CLASS=refnamediv>
<H1>Integer</H1>

<H2>Name</H2>

Integer

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch12-REFSECT1-AUTOID.193">Synopsis</A></h2>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Class Name:<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>java.lang.Integer</tt>

<p>
<DT CLASS=varlistentry>Superclass:<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>java.lang.Number</tt>

<p>
<DT CLASS=varlistentry>Immediate Subclasses:<br>
<DD>

<P CLASS=para>
None

<p>
<DT CLASS=varlistentry>Interfaces Implemented:<br>
<DD>

<P CLASS=para>
None

<p>
<DT CLASS=varlistentry>Availability:<br>
<DD>

<P CLASS=para>
JDK 1.0 or later</DL>
</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch12-REFSECT1-AUTOID.194">Description</A></h2>

<P CLASS=para>
<A NAME="MAN.INTEGER.1"></A>The <tt CLASS=literal>Integer</tt> class provides an object wrapper
for an <tt CLASS=literal>int</tt> value. This is useful when you need
to treat an <tt CLASS=literal>int</tt> value as an object. For example,
there are a number of utility methods that take a reference to an
<tt CLASS=literal>Object</tt> as one of their arguments. You cannot
specify an <tt CLASS=literal>int</tt> value for one of these arguments,
but you can provide a reference to an <tt CLASS=literal>Integer</tt> object
that encapsulates 

the <tt CLASS=literal>int</tt> value. Also,
as of JDK 1.1, the <tt CLASS=literal>Integer</tt> class is necessary to 
support the Reflection API and class literals.

<P CLASS=para>
The <tt CLASS=literal>Integer</tt> class also provides a number
of utility methods for converting <tt CLASS=literal>int</tt> values
to other primitive types and for converting <tt CLASS=literal>int</tt> values
to strings and vice versa.

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch12-REFSECT1-AUTOID.195">Class Summary</A></h2>

<DIV CLASS=screen>
<P>
<PRE>
public final class java.lang.Integer extends java.lang.Number {
    // Constants
    public static final int MAX_VALUE;
    public static final int MIN_VALUE;
    public final static Class TYPE;                    // New in 1.1
    // Constructors
    public Integer(int value);
    public Integer(String s);
    // Class Methods
    public static Integer decode(String nm)            // New in 1.1
    public static Integer getInteger(String nm);
    public static Integer getInteger(String nm, int val);
    public static Integer getInteger(String nm, Integer val);
    public static int parseInt(String s);
    public static int parseInt(String s, int radix;
    public static String toBinaryString(long i);
    public static String toHexString(long i);
    public static String toOctalString(long i);
    public static String toString(int i);
    public static String toString(int i, int radix);
    public static Integer valueOf(String s);
    public static Integer valueOf(String s, int radix);
    // Instance Methods
    public byte byteValue();                           // New in 1.1
    public double doubleValue();
    public boolean equals(Object obj);
    public float floatValue();
    public int hashCode();
    public int intValue();
    public long longValue();
    public short shortValue();                         // New in 1.1
    public String toString();
}
</PRE>
</DIV>

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch12-REFSECT1-AUTOID.196">Constants</A></h2>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch12-REFSECT2-AUTOID.209">MAX_VALUE</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch12-REFSECT3-AUTOID.239"><tt CLASS=literal>public static final int MAX_VALUE = 0x7fffffff // 2147483647</tt></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
The largest value that can be represented by an <tt CLASS=literal>int</tt>.</DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch12-REFSECT2-AUTOID.210">MIN_VALUE</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch12-REFSECT3-AUTOID.240"><tt CLASS=literal>public static final int MIN_VALUE = 0x80000000 // -2147483648</tt></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
The smallest value that can be represented by an <tt CLASS=literal>int</tt>.</DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch12-REFSECT2-AUTOID.211">TYPE</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch12-REFSECT3-AUTOID.241"><tt CLASS=literal>public static final Class TYPE </tt></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Availability<br>
<DD>

<P CLASS=para>
New as of JDK 1.1

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
The <tt CLASS=literal>Class</tt> object that represents the type
<tt CLASS=literal>int</tt>.
It is always true that <tt CLASS=literal>Integer.TYPE</tt> 
<tt CLASS=literal>==</tt> <tt CLASS=literal>int.class</tt>.</DL>
</DIV>

</DIV>

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch12-REFSECT1-AUTOID.197">Constructors</A></h2>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch12-REFSECT2-AUTOID.212">Integer</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch12-REFSECT3-AUTOID.242"><tt CLASS=literal>public Integer(int value)</tt></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>value</tt><br>
<DD>

<P CLASS=para>
The <tt CLASS=literal>int</tt> value to be encapsulated
by this object.</DL>
<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
Creates an <tt CLASS=literal>Integer</tt> object with the specified
<tt CLASS=literal>int</tt> value.</DL>
</DIV>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch12-REFSECT3-AUTOID.243"><tt CLASS=literal>public Integer(String s) throws NumberFormatException</tt></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>s</tt><br>
<DD>

<P CLASS=para>
The string to be made into an <tt CLASS=literal>Integer</tt>
object.</DL>
<p>
<DT CLASS=varlistentry>Throws<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>NumberFormatException</tt><br>
<DD>

<P CLASS=para>
If the sequence of characters in the given <tt CLASS=literal>String</tt>
does not form a valid <tt CLASS=literal>int</tt> literal.</DL>
<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
Constructs an <tt CLASS=literal>Integer</tt> object with the value
specified by the given string. The string should consist of one or
more digit characters. The digit characters can be preceded by a
single `<tt CLASS=literal>-</tt>' character. If the string contains any other characters, the constructor throws a <tt CLASS=literal>NumberFormatException</tt>.</DL>
</DIV>

</DIV>

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch12-REFSECT1-AUTOID.198">Class Methods</A></h2>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch12-REFSECT2-AUTOID.213">decode</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch12-REFSECT3-AUTOID.244"><tt CLASS=literal>public static Integer decode(String nm)</tt></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Availability<br>
<DD>

<P CLASS=para>
New as of JDK 1.1

<p>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>nm</tt><br>
<DD>

<P CLASS=para>
A <tt CLASS=literal>String</tt> representation of the value to be 
encapsulated by an <tt CLASS=literal>Integer</tt> object. If the 
string begins with <tt CLASS=literal>#</tt> or 
<tt CLASS=literal>0x</tt>, it is a radix 16 representation of the value.  
If the string begins with <tt CLASS=literal>0</tt>, it is a radix 
8 representation of the value. Otherwise, it is 

assumed to be a 
radix 10 representation of the value.</DL>
<p>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
An <tt CLASS=literal>Integer</tt> object that encapsulates the given value.

<p>
<DT CLASS=varlistentry>Throws<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>NumberFormatException</tt><br>
<DD>

<P CLASS=para>
If the <tt CLASS=literal>String</tt> contains any nondigit characters 
other than a leading minus sign or the value represented by the 
<tt CLASS=literal>String</tt> is less than <tt CLASS=literal>Integer.MIN_VALUE</tt>
or greater than <tt CLASS=literal>Integer.MAX_VALUE</tt>.</DL>
<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method returns an <tt CLASS=literal>Integer</tt> 
object that encapsulates the given value.</DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch12-REFSECT2-AUTOID.214">getInteger</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch12-REFSECT3-AUTOID.245"><tt CLASS=literal>public static Integer getInteger(String nm)</tt></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>nm</tt><br>
<DD>

<P CLASS=para>
The name of a system property.</DL>
<p>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
The value of the system property as an <tt CLASS=literal>Integer</tt> object,
or an <tt CLASS=literal>Integer</tt> object with the value 0 if the
named property does not exist or cannot be parsed.

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method retrieves the value of the named system property
and returns it as an <tt CLASS=literal>Integer</tt> object. The method
obtains the value of the system property as a <tt CLASS=literal>String</tt>
using <tt CLASS=literal>System.getProperty()</tt>.

<P CLASS=para>
If the value of the property begins with <tt CLASS=literal>0x</tt>
or <tt CLASS=literal>#</tt> and is not followed by a minus sign, the
rest of the value is parsed as a hexadecimal integer. If the value
begins with <tt CLASS=literal>0</tt>, it's parsed as an octal integer;
otherwise it's parsed as a decimal integer.</DL>
</DIV>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch12-REFSECT3-AUTOID.246"><tt CLASS=literal>public static Integer getInteger(String nm, int val)</tt></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>nm</tt><br>
<DD>

<P CLASS=para>
The name of a system property.

<p>
<DT CLASS=varlistentry><tt CLASS=literal>val</tt><br>
<DD>

<P CLASS=para>
A default <tt CLASS=literal>int</tt> value for the property.</DL>
<p>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
The value of the system property as an <tt CLASS=literal>Integer</tt> object,
or an <tt CLASS=literal>Integer</tt> object with the value <tt CLASS=literal>val</tt>
if the named property does not exist or cannot be parsed.

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method retrieves the value of the named system property
and returns it as an <tt CLASS=literal>Integer</tt> object. The method
obtains the value of the system property as a <tt CLASS=literal>String</tt>
using <tt CLASS=literal>System.getProperty()</tt>.

<P CLASS=para>
If the value of the property begins with <tt CLASS=literal>0x</tt>
or <tt CLASS=literal>#</tt> and is not followed by a minus sign, the
rest of the value is parsed as a hexadecimal integer. If the value
begins with <tt CLASS=literal>0</tt>, it's parsed as an octal integer;
otherwise it's parsed as a decimal integer.</DL>
</DIV>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch12-REFSECT3-AUTOID.247"><tt CLASS=literal>public static Integer getInteger(String nm, Integer val)</tt></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>nm</tt><br>
<DD>

<P CLASS=para>
The name of a system property.

<p>
<DT CLASS=varlistentry><tt CLASS=literal>val</tt><br>
<DD>

<P CLASS=para>
A default <tt CLASS=literal>Integer</tt> value for the
property.</DL>
<p>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
The value of the system property as an <tt CLASS=literal>Integer</tt> object,
or the <tt CLASS=literal>Integer</tt> object <tt CLASS=literal>val</tt>
if the named property does not exist or cannot be parsed.

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method retrieves the value of the named system property
and returns it as an <tt CLASS=literal>Integer</tt> object. The method
obtains the value of the system property as a <tt CLASS=literal>String</tt>
using <tt CLASS=literal>System.getProperty()</tt>.

<P CLASS=para>
If the value of the property begins with <tt CLASS=literal>0x</tt>
or <tt CLASS=literal>#</tt> and is not followed by a minus sign, the
rest of the value is parsed as a hexadecimal integer. If the value
begins with <tt CLASS=literal>0</tt>, it's parsed as an octal integer;
otherwise it's as a decimal integer.</DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch12-REFSECT2-AUTOID.215">parseInt</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch12-REFSECT3-AUTOID.248"><DIV CLASS=screen> <P> <PRE> public static int parseInt(String s) throws NumberFormatException </PRE> </DIV></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>s</tt><br>
<DD>

<P CLASS=para>
The <tt CLASS=literal>String</tt> to be converted to
an <tt CLASS=literal>int</tt> value.</DL>
<p>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
The numeric value of the integer represented by the <tt CLASS=literal>String</tt>
object.

<p>
<DT CLASS=varlistentry>Throws<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>NumberFormatException</tt><br>
<DD>

<P CLASS=para>
If the <tt CLASS=literal>String</tt> does not contain
a valid representation of an integer.</DL>
<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method returns the numeric value of the integer represented
by the contents of the given <tt CLASS=literal>String</tt> object. The
<tt CLASS=literal>String</tt> must contain only decimal digits, except
that the first character may be a minus sign.</DL>
</DIV>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch12-REFSECT3-AUTOID.249"><DIV CLASS=screen> <P> <PRE> public static int parseInt(String s, int radix) throws NumberFormatException </PRE> </DIV></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>s</tt><br>
<DD>

<P CLASS=para>
The <tt CLASS=literal>String</tt> to be converted to
an <tt CLASS=literal>int</tt> value.

<p>
<DT CLASS=varlistentry><tt CLASS=literal>radix</tt><br>
<DD>

<P CLASS=para>
The radix used in interpreting the characters in
the <tt CLASS=literal>String</tt> as digits. This value must be in the
range <tt CLASS=literal>Character.MIN_RADIX</tt> to <tt CLASS=literal>Character.MAX_RADIX</tt>.
If <tt CLASS=literal>radix</tt> is in the range 2 through 10, only characters
for which the <tt CLASS=literal>Character.isDigit()</tt> method returns
<tt CLASS=literal>true</tt> are considered to be valid digits.
If <tt CLASS=literal>radix</tt>
is in the range 11 through 36, characters in the ranges
`A' through `Z' and `a' through `z' may be considered valid digits.</DL>
<p>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
The numeric value of the integer represented by the <tt CLASS=literal>String</tt>
object in the specified radix.

<p>
<DT CLASS=varlistentry>Throws<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>NumberFormatException</tt><br>
<DD>

<P CLASS=para>
If the <tt CLASS=literal>String</tt> does not contain
a valid representation of an integer, or <tt CLASS=literal>radix</tt>
is not in the appropriate range.</DL>
<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method returns the numeric value of the integer represented
by the contents of the given <tt CLASS=literal>String</tt> object in
the specified radix. The <tt CLASS=literal>String</tt> must contain
only valid digits of the specified radix, except that the first
character may be a minus sign. The digits are parsed in the specified
radix to produce the numeric value.</DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch12-REFSECT2-AUTOID.216">toBinaryString</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch12-REFSECT3-AUTOID.250"><tt CLASS=literal>public static String toBinaryString(int value)</tt></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>value</tt><br>
<DD>

<P CLASS=para>
The <tt CLASS=literal>int</tt> value to be converted
to a string.</DL>
<p>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
A string that contains the binary representation of the given
value.

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method returns a <tt CLASS=literal>String</tt> object that
contains the representation of the given value as an unsigned binary
number. To convert the given value to an unsigned quantity, the
method simply uses the value as if it were not negative. In other
words, if the given value is negative, the method adds
2^32 to it.
Otherwise the value is used as it is.

<P CLASS=para>
The string returned by this method contains a sequence of
one or more `0' and `1' characters. The method returns "0" if its
argument is <tt CLASS=literal>0</tt>. Otherwise, the string returned
by this method begins with `1'.</DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch12-REFSECT2-AUTOID.217">toHexString</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch12-REFSECT3-AUTOID.251"><tt CLASS=literal>public static String toHexString(int value)</tt></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>value</tt><br>
<DD>

<P CLASS=para>
The <tt CLASS=literal>int</tt> value to be converted
to a string.</DL>
<p>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
A string that contains the hexadecimal representation of the
given value.

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method returns a <tt CLASS=literal>String</tt> object that
contains the representation of the given value as an unsigned hexadecimal
number. To convert the given value to an unsigned quantity, the
method simply uses the value as if it were not negative. In other
words, if the given value is negative, the method adds
2^32 to it.
Otherwise the value is used as it is.

<P CLASS=para>
The string returned by this method contains a sequence of
one or more of the characters `0', `1', `2', `3', `4', `5', `6',
`7', `8', `9', `a', `b', `c', `d', `e', and `f'. The method returns
"0" if its argument is
<tt CLASS=literal>0</tt>. Otherwise, the string returned by this method
does not begin with `0'.

<P CLASS=para>
To produce a string that contains upper- instead
of lowercase letters, use the <tt CLASS=literal>String.toUpperCase()</tt>
method.</DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch12-REFSECT2-AUTOID.218">toOctalString</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch12-REFSECT3-AUTOID.252"><tt CLASS=literal>public static String toOctalString(int value)</tt></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>value</tt><br>
<DD>

<P CLASS=para>
The <tt CLASS=literal>int</tt> value to be converted
to a string.</DL>
<p>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
A string that contains the octal representation of the given
value.

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method returns a <tt CLASS=literal>String</tt> object that
contains a representation of the given value as an unsigned octal
number. To convert the given value to an unsigned quantity, the
method simply uses the value as if it were not negative. In other
words, if the given value is negative, the method adds
2^32 to it.
Otherwise the value is used as it is.

<P CLASS=para>
The string returned by this method contains a sequence of
one or more of the characters `0', `1', `2', `3', `4', `5', `6',
and `7'. The method returns "0" if its
argument is <tt CLASS=literal>0</tt>. Otherwise,
the string returned by this method does not begin with `0'.</DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch12-REFSECT2-AUTOID.219">toString</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch12-REFSECT3-AUTOID.253"><tt CLASS=literal>public static String toString(int i)</tt></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>i</tt><br>
<DD>

<P CLASS=para>
The <tt CLASS=literal>int</tt> value to be converted
to a string.</DL>
<p>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
The string representation of the given value.

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method returns a <tt CLASS=literal>String</tt> object that
contains the decimal representation of the given value.

<P CLASS=para>
This method returns a string that begins with `<tt CLASS=literal>-</tt>' if the given
value is negative. The rest of the string is a sequence of one or
more of the characters `0', `1', `2', `3', `4', `5', `6', `7', `8',
and `9'. This method returns "0" if its argument
is <tt CLASS=literal>0</tt>. Otherwise,
the string returned by this method does not begin with "0" or
"<tt CLASS=literal>-</tt>0".</DL>
</DIV>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch12-REFSECT3-AUTOID.254"><tt CLASS=literal>public static String toString(int i, int radix)</tt></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>i</tt><br>
<DD>

<P CLASS=para>
The <tt CLASS=literal>int</tt> value to be converted
to a string.

<p>
<DT CLASS=varlistentry><tt CLASS=literal>radix</tt><br>
<DD>

<P CLASS=para>
The radix used in converting the value to a string.
This value must be in the range <tt CLASS=literal>Character.MIN_RADIX</tt>
to <tt CLASS=literal>Character.MAX_RADIX</tt>.</DL>
<p>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
The string representation of the given value in the specified
radix.

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method returns a <tt CLASS=literal>String</tt> object that
contains the representation of the given value in the specified
radix.

<P CLASS=para>
This method returns a string that begins with `<tt CLASS=literal>-</tt>' if the given
value is negative. The rest of the string is a sequence of one or
more characters that represent the magnitude of the given value.
The characters that can appear in the sequence are determined by
the value of <tt CLASS=literal>radix</tt>. If <I CLASS=emphasis>N</I>
is the value of <tt CLASS=literal>radix</tt>, the first <I CLASS=emphasis>N</I>
characters on the following line can appear in the sequence:

<DIV CLASS=screen>
<P>
<PRE>
0123456789abcdefghijklmnopqrstuvwxyz
</PRE>
</DIV>

<P CLASS=para>
The method does not verify that <tt CLASS=literal>radix</tt> is
in the proper range. If <tt CLASS=literal>radix</tt> is less than <tt CLASS=literal>Character.MIN_RADIX</tt>
or greater than <tt CLASS=literal>Character.MAX_RADIX</tt>, the value
10 is used instead of the given value.

<P CLASS=para>
This method returns "0" if its argument is <tt CLASS=literal>0</tt>.
Otherwise, the string returned by this method does not begin with
"0" or "<tt CLASS=literal>-</tt>0".</DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch12-REFSECT2-AUTOID.220">valueOf</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch12-REFSECT3-AUTOID.255"><DIV CLASS=screen> <P> <PRE> public static Integer valueOf(String s) throws NumberFormatException </PRE> </DIV></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>s</tt><br>
<DD>

<P CLASS=para>
The string to be made into an <tt CLASS=literal>Integer</tt>
object.</DL>
<p>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
The <tt CLASS=literal>Integer</tt> object constructed from the
string.

<p>
<DT CLASS=varlistentry>Throws<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>NumberFormatException</tt><br>
<DD>

<P CLASS=para>
If the <tt CLASS=literal>String</tt> does not contain
a valid representation of an integer.</DL>
<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
Constructs an <tt CLASS=literal>Integer</tt> object with the value
specified by the given string. The string should consist of one or more digit characters. The digit characters can be preceded by a single `<tt CLASS=literal>-</tt>' character. If the string contains any other characters, the method throws a <tt CLASS=literal>NumberFormatException</tt>.</DL>
</DIV>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch12-REFSECT3-AUTOID.256"><DIV CLASS=screen> <P> <PRE> public static Integer valueOf(String s, int radix) throws NumberFormatException </PRE> </DIV></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>s</tt><br>
<DD>

<P CLASS=para>
The string to be made into an <tt CLASS=literal>Integer</tt>
object.

<p>
<DT CLASS=varlistentry><tt CLASS=literal>radix</tt><br>
<DD>

<P CLASS=para>
The radix used in converting the string to a value.
This value must be in the range <tt CLASS=literal>Character.MIN_RADIX</tt>
to <tt CLASS=literal>Character.MAX_RADIX</tt>.</DL>
<p>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
The <tt CLASS=literal>Integer</tt> object constructed from the
string.

<p>
<DT CLASS=varlistentry>Throws<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>NumberFormatException</tt><br>
<DD>

<P CLASS=para>
If the <tt CLASS=literal>String</tt> does not contain
a valid representation of an integer or <tt CLASS=literal>radix</tt>
is not in the appropriate range.</DL>
<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
Constructs an <tt CLASS=literal>Integer</tt> object with the value
specified by the given string in the specified radix. The string
should consist of one or more digit characters or characters in the
range `A' to `Z' or `a' to `z' that are considered digits in the given
radix. The digit characters can be preceded by a single `<tt CLASS=literal>-</tt>' character. If the string contains any other characters, the method throws a <tt CLASS=literal>NumberFormatException</tt>.</DL>
</DIV>

</DIV>

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch12-REFSECT1-AUTOID.199">Instance Methods</A></h2>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch12-REFSECT2-AUTOID.221">byteValue</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch12-REFSECT3-AUTOID.257"><tt CLASS=literal>public byte byteValue()</tt></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Availability<br>
<DD>

<P CLASS=para>
New as of JDK 1.1

<p>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
The value of this object as a <tt CLASS=literal>byte</tt>.

<p>
<DT CLASS=varlistentry>Overrides<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>Number.byteValue()</tt>

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method returns the value of this object as a <tt CLASS=literal>byte</tt>.
The high order bits of the value are discarded.</DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch12-REFSECT2-AUTOID.222">doubleValue</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch12-REFSECT3-AUTOID.258"><tt CLASS=literal>public double doubleValue()</tt></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
The value of this object as a <tt CLASS=literal>double</tt>.

<p>
<DT CLASS=varlistentry>Overrides<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>Number.doubleValue()</tt>

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method returns the value of this object as a <tt CLASS=literal>double</tt>.</DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch12-REFSECT2-AUTOID.223">equals</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch12-REFSECT3-AUTOID.259"><tt CLASS=literal>public boolean equals(Object obj)</tt></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Parameters<br>
<DD>

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><tt CLASS=literal>obj</tt><br>
<DD>

<P CLASS=para>
The object to be compared with this object.</DL>
<p>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>true</tt> if the objects are equal; <tt CLASS=literal>false</tt>
if they are not.

<p>
<DT CLASS=varlistentry>Overrides<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>Object.equals()</tt>

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method returns <tt CLASS=literal>true</tt> if <tt CLASS=literal>obj</tt>
is an instance of <tt CLASS=literal>Integer</tt> and it contains the
same value as the object this method is associated with.</DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch12-REFSECT2-AUTOID.224">floatValue</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch12-REFSECT3-AUTOID.260"><tt CLASS=literal>public float floatValue()</tt></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
The value of this object as a <tt CLASS=literal>float</tt>.

<p>
<DT CLASS=varlistentry>Overrides<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>Number.floatValue()</tt>

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method returns the value of this object as a <tt CLASS=literal>float</tt>.
Rounding may occur.</DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch12-REFSECT2-AUTOID.225">hashCode</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch12-REFSECT3-AUTOID.261"><tt CLASS=literal>public int hashCode()</tt></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
A hashcode based on the <tt CLASS=literal>int</tt> value of the
object.

<p>
<DT CLASS=varlistentry>Overrides<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>Object.hashCode()</tt>

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method returns a hashcode computed from the value of
this object.</DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch12-REFSECT2-AUTOID.226">intValue</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch12-REFSECT3-AUTOID.262"><tt CLASS=literal>public int intValue()</tt></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
The value of this object as an <tt CLASS=literal>int</tt>.

<p>
<DT CLASS=varlistentry>Overrides<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>Number.intValue()</tt>

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method returns the value of this object as an <tt CLASS=literal>int</tt>.</DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch12-REFSECT2-AUTOID.227">longValue</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch12-REFSECT3-AUTOID.263"><tt CLASS=literal>public long longValue()</tt></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
The value of this object as a <tt CLASS=literal>long</tt>.

<p>
<DT CLASS=varlistentry>Overrides<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>Number.longValue()</tt>

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method returns the value of this object as a <tt CLASS=literal>long</tt>.</DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch12-REFSECT2-AUTOID.228">shortValue</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch12-REFSECT3-AUTOID.264"><tt CLASS=literal>public short shortValue()</tt></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Availability<br>
<DD>

<P CLASS=para>
New as of JDK 1.1

<p>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
The value of this object as a <tt CLASS=literal>short</tt>.

<p>
<DT CLASS=varlistentry>Overrides<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>Number.shortValue()</tt>

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method returns the value of this object as a <tt CLASS=literal>short</tt>.
The high order bits of the value are discarded.</DL>
</DIV>

</DIV>

<DIV CLASS=refsect2>
<h3 CLASS=refsect2><A CLASS="TITLE" NAME="ch12-REFSECT2-AUTOID.229">toString</A></h3>

<DIV CLASS=refsect3>
<h4 CLASS=refsect3><A CLASS="TITLE" NAME="ch12-REFSECT3-AUTOID.265"><tt CLASS=literal>public String toString()</tt></A></h4>

<DL CLASS=variablelist>
<DT CLASS=varlistentry>Returns<br>
<DD>

<P CLASS=para>
The string representation of the value of this object.

<p>
<DT CLASS=varlistentry>Overrides<br>
<DD>

<P CLASS=para>
<tt CLASS=literal>Object.toString()</tt>

<p>
<DT CLASS=varlistentry>Description<br>
<DD>

<P CLASS=para>
This method returns a <tt CLASS=literal>String</tt> object that
contains the decimal representation of the value of this object.

<P CLASS=para>
This method returns a string that begins with `<tt CLASS=literal>-</tt>' if the value
is negative. The rest of the string is a sequence of one or more
of the characters `0', `1', `2', `3', `4', `5', `6', `7', `8', and
`9'. This method returns "0" if the value of
the object is <tt CLASS=literal>0</tt>.
Otherwise, the string returned by this method does not begin with
"0" or "<tt CLASS=literal>-</tt>0".</DL>
</DIV>

</DIV>

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch12-REFSECT1-AUTOID.200">Inherited Methods</A></h2>

<DIV CLASS=informaltable>
<P>
<TABLE CLASS=INFORMALTABLE>
<TR CLASS=row>
<TH ALIGN="left">

<P CLASS=para>
Method</TH>
<TH ALIGN="left">

<P CLASS=para>
Inherited From</TH>
<TH ALIGN="left">

<P CLASS=para>
Method</TH>
<TH ALIGN="left">

<P CLASS=para>
Inherited From</TH>
</TR>
<TR CLASS=row>
<TD ALIGN="left">

<P CLASS=para>
<tt CLASS=literal>clone()</tt></TD>
<TD ALIGN="left">

<P CLASS=para>
<tt CLASS=literal>Object</tt></TD>
<TD ALIGN="left">

<P CLASS=para>
<tt CLASS=literal>finalize()</tt></TD>
<TD ALIGN="left">

<P CLASS=para>
<tt CLASS=literal>Object</tt></TD>
</TR>
<TR CLASS=row>
<TD ALIGN="left">

<P CLASS=para>
<tt CLASS=literal>getClass()</tt></TD>
<TD ALIGN="left">

<P CLASS=para>
<tt CLASS=literal>Object</tt></TD>
<TD ALIGN="left">

<P CLASS=para>
<tt CLASS=literal>notify()</tt></TD>
<TD ALIGN="left">

<P CLASS=para>
<tt CLASS=literal>Object</tt></TD>
</TR>
<TR CLASS=row>
<TD ALIGN="left">

<P CLASS=para>
<tt CLASS=literal>notifyAll()</tt></TD>
<TD ALIGN="left">

<P CLASS=para>
<tt CLASS=literal>Object</tt></TD>
<TD ALIGN="left">

<P CLASS=para>
<tt CLASS=literal>wait()</tt></TD>
<TD ALIGN="left">

<P CLASS=para>
<tt CLASS=literal>Object</tt></TD>
</TR>
<TR CLASS=row>
<TD ALIGN="left">

<P CLASS=para>
<tt CLASS=literal>wait(long)</tt></TD>
<TD ALIGN="left">

<P CLASS=para>
<tt CLASS=literal>Object</tt></TD>
<TD ALIGN="left">

<P CLASS=para>
<tt CLASS=literal>wait(long, int)</tt></TD>
<TD ALIGN="left">

<P CLASS=para>
<tt CLASS=literal>Object</tt></TD>
</TR>
</TABLE>
<P>
</DIV>

</DIV>

<DIV CLASS=refsect1>
<h2 CLASS=refsect1><A CLASS="TITLE" NAME="ch12-REFSECT1-AUTOID.201">See Also</A></h2>

<P CLASS=para>
<tt CLASS=literal>Character</tt>, 
<tt CLASS=literal>Class</tt>, 
<tt CLASS=literal>Long</tt>, 
<tt CLASS=literal>Number</tt>, 
<tt CLASS=literal>NumberFormatException</tt>, 
<tt CLASS=literal>String</tt>, 
<tt CLASS=literal>System</tt>
</DIV>


<DIV CLASS=htmlnav>

<P>
<HR align=left width=515>
<table width=515 border=0 cellpadding=0 cellspacing=0>
<tr>
<td width=172 align=left valign=top><A HREF="ch12_29.htm"><IMG SRC="gifs/txtpreva.gif" ALT="Previous" border=0></A></td>
<td width=171 align=center valign=top><a href="index.htm"><img src='gifs/txthome.gif' border=0 alt='Home'></a></td>
<td width=172 align=right valign=top><A HREF="ch12_31.htm"><IMG SRC="gifs/txtnexta.gif" ALT="Next" border=0></A></td>
</tr>
<tr>
<td width=172 align=left valign=top>IndexOutOfBoundsException</td>
<td width=171 align=center valign=top><a href="index/idx_0.htm"><img src='gifs/index.gif' alt='Book Index' border=0></a></td>
<td width=172 align=right valign=top>InstantiationError</td>
</tr>
</table>
<hr align=left width=515>

<IMG SRC="gifs/smnavbar.gif" USEMAP="#map" BORDER=0> 
<MAP NAME="map"> 
<AREA SHAPE=RECT COORDS="0,0,108,15" HREF="../javanut/index.htm"
alt="Java in a Nutshell"> 
<AREA SHAPE=RECT COORDS="109,0,200,15" HREF="../langref/index.htm" 
alt="Java Language Reference"> 
<AREA SHAPE=RECT COORDS="203,0,290,15" HREF="../awt/index.htm" 
alt="Java AWT"> 
<AREA SHAPE=RECT COORDS="291,0,419,15" HREF="../fclass/index.htm" 
alt="Java Fundamental Classes"> 
<AREA SHAPE=RECT COORDS="421,0,514,15" HREF="../exp/index.htm" 
alt="Exploring Java"> 
</MAP>
</DIV>

</BODY>
</HTML>
